package cn.maidouya.hrm.controller;

import org.apache.tomcat.jni.OS;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Console;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

@RestController
public class DeptController {

    @RequestMapping("/dept/list")
    @PreAuthorize("hasAuthority('employee:list')")
    public String list(){
        return "dept.list";
    }

    @RequestMapping("/dept/add")
    @PreAuthorize("hasAuthority('employee:add')")
    public String add(){
        return "dept.add";
    }

    @RequestMapping("/dept/update")
    @PreAuthorize("hasAuthority('employee:update')")
    public String update(){
        return "dept.update";
    }

    @RequestMapping("/dept/delete")
    @PreAuthorize("hasAuthority('employee:delete')")
    public String delete(){
        return "dept.delete";
    }

    public static void main(String[] args) {
        // 双层for循环 冒泡
        ArrayList<Integer> list = new ArrayList<Integer>();
        Collections.addAll(list,9,7,8,0,5,2,1,6);
        for (int i = 0; i < list.size(); i++) {
                for (int j = 1; j < list.size(); j++) {
                    Integer temp;
                    // [0, 1, 2, 5, 6, 7, 8]
                        if (list.get(j-1) > list.get(j)) { // 比较两个整数的大小
                            temp = list.get(j - 1);
                            list.set((j - 1),list.get(j));
                            list.set(j, temp); // 交换数据
                        }
                }
        }
        System.out.println(list);

    }
}